<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function fn() {
            console.log(1);
        }
        fn();
        //写法
        //(function(){}()) 或者(function(){}());
        (function() {
            console.log(2);
        })();
        (function(a) {
            console.log(a); //a=1
        })(1);
        (function(a, b) {
            console.log(a + b); //1+2=3
        })(1, 2);
        (function(a, b) {
            console.log(a + b);
        }(2, 3));
    </script>
</body>

</html>